import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bmfmap_example/http/http.dart';
import 'package:flutter_bmfmap_example/pages/homepage/pages/Equipment_message/tool/tool.dart';

class Equipment_all_value_card extends StatefulWidget {
  Equipment_all_value_card({Key key,this.typeId,this.deviceId,this.content,this.created}) : super(key: key);
  int typeId;
  int deviceId;
  String created;
  String content;
  
  @override
  _Equipment_all_value_cardState createState() =>
      _Equipment_all_value_cardState();
}

class _Equipment_all_value_cardState extends State<Equipment_all_value_card> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        setState(() {});
      },
      child: Container(
          child: Column(
        children: [
          Text(
            getTime(widget.created),
            style: TextStyle(color: Colors.black38),
          ),
          Container(
            child: Column(children: [
              Container(
                width: 300,
                child: Text(
                  '异常警告',
                  textAlign: TextAlign.left,
                  style: TextStyle(
                    color: Colors.black87,
                    fontSize: 20,
                  ),
                ),
              ),
              Container(
                width: 300,
                margin: EdgeInsets.only(top: 8),
                child: Text(
                  '${getTime(widget.created)}，您的${Tool.getName(widget.typeId, widget.deviceId)}出现${widget.content}，请及时查看。',
                  style: TextStyle(
                    color: Colors.black54,
                    fontSize: 16,
                  ),
                ),
              ),
            ]),
            padding: EdgeInsets.all(8),
            margin: EdgeInsets.all(8),
            height: 160,
            width: 320,
            decoration: new BoxDecoration(
                color: Colors.white,
                borderRadius: new BorderRadius.circular((10.0)),
                boxShadow: [
                  BoxShadow(
                      color: Colors.black12,
                      offset: Offset(0.0, 0.0), //阴影xy轴偏移量
                      blurRadius: 5.0, //阴影模糊程度
                      spreadRadius: 0.1 //阴影扩散程度
                      )
                ]),
          )
        ],
      )),
    );
  }
  getTime(String created){
    DateTime Ttime = DateTime.parse(created).add(new Duration(hours: 8));
    String time=Ttime.year.toString()+'年'+Ttime.month.toString()+'月'+Ttime.day.toString()+'日 '+Ttime.hour.toString()+':'+Ttime.minute.toString()+':'+Ttime.second.toString();
    return time;
  }
  
}
